import 'dart:convert' show json;

class MusicRadioInfo {
  int code;
  String message;
  List<MusicRadio> result;

  MusicRadioInfo.fromParams({this.code, this.message, this.result});

  factory MusicRadioInfo(jsonStr) => jsonStr == null
      ? null
      : jsonStr is String
          ? new MusicRadioInfo.fromJson(json.decode(jsonStr))
          : new MusicRadioInfo.fromJson(jsonStr);

  MusicRadioInfo.fromJson(jsonRes) {
    code = jsonRes['code'];
    message = jsonRes['message'];
    result = jsonRes['result'] == null ? null : [];

    for (var resultItem in result == null ? [] : jsonRes['result']) {
      result
          .add(resultItem == null ? null : new MusicRadio.fromJson(resultItem));
    }
  }

  @override
  String toString() {
    return '{"code": $code,"message": ${message != null ? '${json.encode(message)}' : 'null'},"result": $result}';
  }
}

class MusicRadio {
  int cid;
  String title;
  List<RadioItem> channellist;

  MusicRadio.fromParams({this.cid, this.title, this.channellist});

  MusicRadio.fromJson(jsonRes) {
    cid = jsonRes['cid'];
    title = jsonRes['title'];
    channellist = jsonRes['channellist'] == null ? null : [];

    for (var channellistItem
        in channellist == null ? [] : jsonRes['channellist']) {
      channellist.add(channellistItem == null
          ? null
          : new RadioItem.fromJson(channellistItem));
    }
  }

  @override
  String toString() {
    return '{"cid": $cid,"title": ${title != null ? '${json.encode(title)}' : 'null'},"channellist": $channellist}';
  }
}

class RadioItem {
  int value;
  String cate_name;
  String cate_sname;
  String ch_name;
  String channelid;
  String name;
  String thumb;
  String artistid;
  String avatar;

  RadioItem.fromParams(
      {this.value,
      this.cate_name,
      this.cate_sname,
      this.ch_name,
      this.channelid,
      this.name,
      this.thumb,
      this.artistid,
      this.avatar});

  RadioItem.fromJson(jsonRes) {
    value = jsonRes['value'];
    cate_name = jsonRes['cate_name'];
    cate_sname = jsonRes['cate_sname'];
    ch_name = jsonRes['ch_name'];
    channelid = jsonRes['channelid'];
    name = jsonRes['name'];
    thumb = jsonRes['thumb'];
    artistid = jsonRes['artistid'];
    avatar = jsonRes['avatar'];
  }

  @override
  String toString() {
    return '{"value": $value,"cate_name": ${cate_name != null ? '${json.encode(cate_name)}' : 'null'},"cate_sname": ${cate_sname != null ? '${json.encode(cate_sname)}' : 'null'},"ch_name": ${ch_name != null ? '${json.encode(ch_name)}' : 'null'},"channelid": ${channelid != null ? '${json.encode(channelid)}' : 'null'},"name": ${name != null ? '${json.encode(name)}' : 'null'},'
        '"thumb": ${thumb != null ? '${json.encode(thumb)}' : 'null'},'
        '"artistid": ${artistid != null ? '${json.encode(artistid)}' : 'null'},'
        '"avatar": ${avatar != null ? '${json.encode(avatar)}' : 'null'}'
        '}';
  }
}
